package cn.wyu.web;

import cn.wyu.pojo.Information;
import cn.wyu.service.ShopCarService;
import cn.wyu.service.ShopCarServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/informationListServlet")
public class ShopCarListServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.调用UserService完成查询
        ShopCarService service = new ShopCarServiceImpl();
        List<Information> informations = service.findAll();
        //2.将list存入request域
        request.setAttribute("informations",informations);
        //3.转发到list.jsp
        request.getRequestDispatcher("/buyCar.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
